package com.sinaapp.kjWeb.controller;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mysql.jdbc.StringUtils;
import com.sinaapp.kjWeb.pojo.AjaxResult;
import com.sinaapp.kjWeb.pojo.KaiJieUser;
import com.sinaapp.kjWeb.service.KjEmployService;
/*
 *auth:徐疆
 *date 2014-1-22 下午10:26:08
 */
@Controller()
@RequestMapping("/kj")
public class KjController {
	/**
	 * Logger for this class
	 */
	private static final Logger logger = Logger.getLogger(KjController.class);
	@Resource(name="kjEmployService")
	private KjEmployService service;
	@RequestMapping("/")
	public String welcome() {
		return "kj/kjContact";
	}

	@RequestMapping("/autoCheckIn")
	@ResponseBody
	public AjaxResult autoCheckIn(@RequestParam("employId")String employId,@RequestParam("email")String email) {
		KaiJieUser kju=new KaiJieUser();
		if(!StringUtils.isNullOrEmpty(email)){
			kju.setEmail(email);
		}
		kju.setEmployID(employId);
		kju.setAutoCheck(1);
		kju.setIp("127.0.0.1");
		boolean success=service.updateAutoCheck(kju);
		AjaxResult t=new AjaxResult();
		if(success){
			t.setResultContext("成功激活，注意下次查看签到结果喔");
		}else{
			t.setResultContext("没有此员工号");
		}
		return t;
	}
	
	@RequestMapping("/pauseCheckIn")
	@ResponseBody
	public AjaxResult pauseCheckIn(@RequestParam("employId")String employId) {
		AjaxResult t=new AjaxResult();
		boolean success=service.updatePauseCheck(employId);
		if(success){
			t.setResultContext("成功停止此员工号自动签到");
		}else{
			t.setResultContext("没有此员工号");
		}
		return t;
	}
	
	@RequestMapping("/addCheckPerson")
	public String addCheckPerson() {
		return null;
	}

	@RequestMapping("/editCheckPerson")
	public String editCheckPerson() {
		return null;
	}

	@RequestMapping("/delCheckPerson")
	public String delCheckPerson() {
		return null;
	}

}
